package com.learn.game_challenger;

import com.learn.game_challenger.UI.setPlayer;
import com.learn.game_challenger.UI.chooseUp;
import com.learn.game_challenger.entity.role;
import com.learn.game_challenger.service.behavior;

import java.util.Scanner;

public class Main {
    public static void main(String[] args) {

        setPlayer setPlayer = new setPlayer();
        role challenger = setPlayer.SetPlayer();
        System.out.println("输入回车开始冒险");
        Scanner scanner = new Scanner(System.in);
        scanner.nextLine();
        role[] boss = new role[]{
                new role("哥布林", 5, 0, 30),
                new role("普通骷髅士兵", 5, 5, 40),
                new role("精英骷髅士官长", 10, 5, 50),
                new role("骷髅大统帅", 10, 10, 60),
                new role("最终BOSS", 20, 10, 60),
        };
        boss[0].Show();
        int i = 0;
        while (i<boss.length){
            int index = 0;
            behavior behavior1 = new behavior(challenger, boss[i]);
            if(behavior1.canPass(challenger, boss[i])) {
                while (challenger.getHealth() > 0 && boss[i].getHealth() > 0 && index <= 20) {
                    behavior1.hit(challenger, boss[i]);
                    index++;
                    if (behavior1.isKill(boss[i])) {
                        System.out.println("你战胜了"+boss[i].getName()+"!\n");
                        if(i == boss.length-1){
                            i = 12;
                            break;
                        }
                        chooseUp chooseUp1 = new chooseUp();
                        System.out.println("下一个boss为" + boss[++i].getName());
                        boss[i].Show();
                        System.out.println(challenger.getName() + "当前属性为");
                        challenger.Show();
                        chooseUp1.ChooseUp(challenger, boss[i]);
                        break;
                    }
                    behavior behavior2 = new behavior(boss[i], challenger);
                    behavior2.hit(boss[i], challenger);
                    if (behavior2.isKill(challenger) || index == 20) {
                        System.out.println("你输了");
                        i = 10;
                        break;
                    }
                }
            }
            else {
                break;
            }
        if(i==12){
            System.out.println("恭喜你通过了所有boss");
        }
        }
    }
}
